<html>
<head><meta charset="utf-8"><title>Lifetime capturing in impl Trait · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html">Lifetime capturing in impl Trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214588253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214588253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214588253">(Oct 26 2020 at 15:26)</a>:</h4>
<p>Is there a way around the error in <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=12da40d86b5d1e6835546f707762cad3">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=12da40d86b5d1e6835546f707762cad3</a>, short of waiting for Chalk? :)</p>



<a name="214588420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214588420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214588420">(Oct 26 2020 at 15:27)</a>:</h4>
<p>Waiting for type alias impl trait?</p>



<a name="214588870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214588870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214588870">(Oct 26 2020 at 15:31)</a>:</h4>
<p>so there's no way to opt out of capturing the input type?</p>



<a name="214588988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214588988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214588988">(Oct 26 2020 at 15:31)</a>:</h4>
<p>No</p>



<a name="214589077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589077">(Oct 26 2020 at 15:32)</a>:</h4>
<p>Okay, maybe I'm missing it, but what exactly is causing the error here...</p>



<a name="214589184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589184">(Oct 26 2020 at 15:33)</a>:</h4>
<p>The return type of <code>bar(a)</code> is <code>bar::&lt;T&gt;::opaque</code>, which only outlives <code>'static</code> if <code>T</code> does.</p>



<a name="214589250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589250">(Oct 26 2020 at 15:33)</a>:</h4>
<p>hmm</p>



<a name="214589459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589459">(Oct 26 2020 at 15:35)</a>:</h4>
<p>That's weird</p>



<a name="214589526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589526">(Oct 26 2020 at 15:35)</a>:</h4>
<p>But yeah, <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=da34566376a5c8020b7792210c7b9021">this</a> works</p>



<a name="214589667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589667">(Oct 26 2020 at 15:36)</a>:</h4>
<p>I find it highly surprising that there's that kind of difference between using a type alias and not using it</p>



<a name="214589683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589683">(Oct 26 2020 at 15:36)</a>:</h4>
<p>will that remain true after TAIT goes stable?</p>



<a name="214589778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214589778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214589778">(Oct 26 2020 at 15:37)</a>:</h4>
<p>(apparently this is <a href="https://github.com/rust-lang/rust/issues/42940">https://github.com/rust-lang/rust/issues/42940</a>?)</p>



<a name="214592657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Lifetime%20capturing%20in%20impl%20Trait/near/214592657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Lifetime.20capturing.20in.20impl.20Trait.html#214592657">(Oct 26 2020 at 15:54)</a>:</h4>
<p>And I just filed <a href="https://github.com/rust-lang/rust/issues/78402">https://github.com/rust-lang/rust/issues/78402</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>